Micron Document
<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Davis–Putnam algorithm</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Davis%E2%80%93Putnam_algorithm"> <link href="./mw/ext.math.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Davis–Putnam_algorithm rootpage-Davis–Putnam_algorithm skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Davis–Putnam algorithm</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<p>In <a href="Logic" title="Logic">logic</a> and <a href="Computer_science" title="Computer science">computer science</a>, the <b>Davis–Putnam algorithm</b> was developed by <a href="Martin_Davis_(mathematician)" title="Martin Davis (mathematician)">Martin Davis</a> and <a href="Hilary_Putnam" title="Hilary Putnam">Hilary Putnam</a> for checking the validity of a <a href="First-order_logic" title="First-order logic">first-order logic</a> formula using a <a href="Resolution_(logic)" title="Resolution (logic)">resolution</a>-based decision procedure for <a href="Propositional_logic" title="Propositional logic">propositional logic</a>. Since the set of valid first-order formulas is <a href="Recursively_enumerable" class="mw-redirect" title="Recursively enumerable">recursively enumerable</a> but not <a href="Recursive_set" class="mw-redirect" title="Recursive set">recursive</a>, there exists no general algorithm to solve this problem. Therefore, the Davis–Putnam algorithm only terminates on valid formulas. Today, the term "Davis–Putnam algorithm" is often used synonymously with the resolution-based propositional decision procedure (<b>Davis–Putnam procedure</b>) that is actually only one of the steps of the original algorithm.
</p>
<div class="mw-heading mw-heading2"><h2 id="Overview">Overview</h2></div>

<p>The procedure is based on <a href="Herbrand's_theorem" title="Herbrand's theorem">Herbrand's theorem</a>, which implies that an <a href="Satisfiable" class="mw-redirect" title="Satisfiable">unsatisfiable</a> formula has an unsatisfiable <a href="Ground_instance" class="mw-redirect" title="Ground instance">ground instance</a>, and on the fact that a formula is valid if and only if its negation is unsatisfiable. Taken together, these facts imply that to prove the validity of <i>φ</i> it is enough to prove that a ground instance of <i>¬φ</i> is unsatisfiable. If <i>φ</i> is not valid, then the search for an unsatisfiable ground instance will not terminate.
</p><p>The procedure for checking validity of a formula <i>φ</i> roughly consists of these three parts:
</p>
<ul><li>put the formula <i>¬φ</i> in <a href="Prenex" class="mw-redirect" title="Prenex">prenex</a> form and eliminate quantifiers</li>
<li>generate all propositional ground instances, one by one</li>
<li>check if each instance is satisfiable.
<ul><li>If some instance is unsatisfiable, then return that <i>φ</i> is valid. Else continue checking.</li></ul></li></ul>
<p>The last part is a <a href="SAT_solver" title="SAT solver">SAT solver</a> based on <a href="Resolution_(logic)" title="Resolution (logic)">resolution</a> (as seen on the illustration), with an eager use of <a href="Unit_propagation" title="Unit propagation">unit propagation</a> and pure literal elimination (elimination of clauses with variables that occur only positively or only negatively in the formula).
</p>
<div style="border:1px solid #cccccc; background-color:var(--background-color-neutral-subtle, #f8f9fa); color: inherit; padding:4px;">
<pre><b>Algorithm</b> DP SAT solver
Input: A set of clauses Φ.
Output: A Truth Value: true if Φ can be satisfied, false otherwise.
</pre>
<pre><b>function</b> DP-SAT(Φ)
<b>repeat</b>
// <i>unit propagation:</i>
<b>while</b> Φ contains a unit clause {<i>l</i>} <b>do</b>
<b>for every</b> clause <i>c</i> in Φ that contains <i>l</i> <b>do</b>
Φ ← <i>remove-from-formula</i>(<i>c</i>, Φ);
<b>for every</b> clause <i>c</i> in Φ that contains ¬<i>l</i> <b>do</b>
Φ ← <i>remove-from-formula</i>(<i>c</i>, Φ);
Φ ← <i>add-to-formula</i>(<i>c</i> \ {¬<i>l</i>}, Φ);
// <i>eliminate clauses not in normal form:</i>
<b>for every</b> clause <i>c</i> in Φ that contains both a literal <i>l</i> and its negation ¬<i>l</i> <b>do</b>
Φ ← <i>remove-from-formula</i>(<i>c</i>, Φ);
// <i>pure literal elimination:</i>
<b>while</b> there is a literal <i>l</i> all of which occurrences in Φ have the same polarity <b>do</b>
<b>for every</b> clause <i>c</i> in Φ that contains <i>l</i> <b>do</b>
Φ ← <i>remove-from-formula</i>(<i>c</i>, Φ);
// <i>stopping conditions:</i>
<b>if</b> Φ is empty <b>then</b>
<b>return</b> true;
<b>if</b> Φ contains an empty clause <b>then</b>
<b>return</b> false;
// <i>Davis-Putnam procedure:</i>
pick a literal <i>l</i> that occurs with both polarities in Φ
<b>for every</b> clause <i>c</i> in Φ containing <i>l</i> and every clause <i>n</i> in Φ containing its negation ¬<i>l</i> <b>do</b>
// <i>resolve c with n:</i>
<i>r</i> ← (<i>c</i> \ {<i>l</i>}) ∪ (<i>n</i> \ {¬<i>l</i>});
Φ ← <i>add-to-formula</i>(<i>r</i>, Φ);
<b>for every</b> clause <i>c</i> that contains <i>l</i> or ¬<i>l</i> <b>do</b>
Φ ← <i>remove-from-formula</i>(<i>c</i>, Φ);
</pre>
<ul><li><small>"←" denotes <a href="Assignment_(computer_science)" title="Assignment (computer science)">assignment</a>. For instance, "<i>largest</i> ← <i>item</i>" means that the value of <i>largest</i> changes to the value of <i>item</i>.</small></li>
<li><small>"<b>return</b>" terminates the algorithm and outputs the following value.</small></li></ul>
</div>
<p>At each step of the SAT solver, the intermediate formula generated is <a href="Equisatisfiable" class="mw-redirect" title="Equisatisfiable">equisatisfiable</a>, but possibly not <a href="Logical_equivalence" title="Logical equivalence">equivalent</a>, to the original formula. The resolution step leads to a worst-case exponential blow-up in the size of the formula.
</p><p>The <a href="Davis%E2%80%93Putnam%E2%80%93Logemann%E2%80%93Loveland_algorithm" class="mw-redirect" title="Davis–Putnam–Logemann–Loveland algorithm">Davis–Putnam–Logemann–Loveland algorithm</a> is a 1962 refinement of the propositional satisfiability step of the Davis–Putnam procedure which requires only a linear amount of memory in the worst case. It eschews the resolution for <i>the splitting rule</i>: a backtracking algorithm that chooses a literal <i>l</i>, and then recursively checks if a simplified formula with <i>l</i> assigned a true value is satisfiable or if a simplified formula with <i>l</i> assigned false is. It still forms the basis for today's (as of 2015) most efficient complete <a href="SAT_solver" title="SAT solver">SAT solvers</a>.
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="Herbrandization" title="Herbrandization">Herbrandization</a></li></ul>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<ul><li><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */


.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}


/* end https://en.wikipedia.org/ */
</style><cite id="CITEREFDavisPutnam,_Hilary1960" class="citation journal cs1">Davis, Martin; Putnam, Hilary (1960). <a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F321033.321034">"A Computing Procedure for Quantification Theory"</a>. <i><a href="Journal_of_the_ACM" title="Journal of the ACM">Journal of the ACM</a></i>. <b>7</b> (3): <span class="nowrap">201–</span>215. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F321033.321034">10.1145/321033.321034</a></span>.</cite></li>
<li><cite id="CITEREFDavisLogemann,_GeorgeLoveland,_Donald1962" class="citation journal cs1">Davis, Martin; Logemann, George; Loveland, Donald (1962). <a rel="nofollow" class="external text" href="http://portal.acm.org/citation.cfm?doid=368273.368557">"A Machine Program for Theorem Proving"</a>. <i><a href="Communications_of_the_ACM" title="Communications of the ACM">Communications of the ACM</a></i>. <b>5</b> (7): <span class="nowrap">394–</span>397. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F368273.368557">10.1145/368273.368557</a>. <a href="Hdl_(identifier)" class="mw-redirect" title="Hdl (identifier)">hdl</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://hdl.handle.net/2027%2Fmdp.39015095248095">2027/mdp.39015095248095</a></span>.</cite></li>
<li><cite id="CITEREFR._DechterI._Rish" class="citation conference cs1">R. Dechter; I. Rish. "Directional Resolution: The Davis–Putnam Procedure, Revisited". In J. Doyle and E. Sandewall and P. Torasso (ed.). <i>Principles of Knowledge Representation and Reasoning: Proc. of the Fourth International Conference (KR'94)</i>. Kaufmann. pp.&nbsp;<span class="nowrap">134–</span>145.</cite></li>
<li><cite id="CITEREFJohn_Harrison2009" class="citation book cs1">John Harrison (2009). <span class="id-lock-limited" title="Free access subject to limited trial, subscription normally required"><a rel="nofollow" class="external text" href="https://archive.org/details/handbookpractica00harr"><i>Handbook of practical logic and automated reasoning</i></a></span>. Cambridge University Press. pp.&nbsp;<a rel="nofollow" class="external text" href="https://archive.org/details/handbookpractica00harr/page/n100">79</a>–90. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>978-0-521-89957-4</bdi>.</cite></li></ul></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2024-08-05" href="https://en.wikipedia.org/wiki/?title=Davis%E2%80%93Putnam_algorithm&amp;oldid=1238818652">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>

</body></html>